<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="vue," />





  <link rel="alternate" href="/rss2.xml" title="rainlevo" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/images/panda.ico?v=5.1.1" />






<meta name="description" content="drop-cli 一个简单的脚手架,可添加不同的模版/框架 1. 安装并查看drop-cli的模版 12$ npm install drop-cli -g$ drop-cli list 2. 选择模板并创建自己的项目12345$ drop-cli init$ gulp-html-front // 输入一个模版$ gulp-html-test  // 输入自己的项目名称$ cd gulp-html-">
<meta name="keywords" content="vue">
<meta property="og:type" content="article">
<meta property="og:title" content="一个简单的脚手架drop-cli,vue的组件库模版，移动端架构和pc管理后台模版">
<meta property="og:url" content="http://yoursite.com/2018/08/17/vue-npm-framework/index.html">
<meta property="og:site_name" content="rainlevo">
<meta property="og:description" content="drop-cli 一个简单的脚手架,可添加不同的模版/框架 1. 安装并查看drop-cli的模版 12$ npm install drop-cli -g$ drop-cli list 2. 选择模板并创建自己的项目12345$ drop-cli init$ gulp-html-front // 输入一个模版$ gulp-html-test  // 输入自己的项目名称$ cd gulp-html-">
<meta property="og:updated_time" content="2018-09-13T03:02:14.807Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="一个简单的脚手架drop-cli,vue的组件库模版，移动端架构和pc管理后台模版">
<meta name="twitter:description" content="drop-cli 一个简单的脚手架,可添加不同的模版/框架 1. 安装并查看drop-cli的模版 12$ npm install drop-cli -g$ drop-cli list 2. 选择模板并创建自己的项目12345$ drop-cli init$ gulp-html-front // 输入一个模版$ gulp-html-test  // 输入自己的项目名称$ cd gulp-html-">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"hide","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: 'DVAW9RHYF1',
      apiKey: '44c3280dbdddc5df47394aa4c557aba8',
      indexName: 'rain',
      hits: {"per_page":10},
      labels: {"input_placeholder":"输入关键词进行搜索","hits_empty":"没有找到关于\" ${query} \"的文章","hits_stats":"共找到 ${hits} 篇文章，花了 ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2018/08/17/vue-npm-framework/"/>





  <title>一个简单的脚手架drop-cli,vue的组件库模版，移动端架构和pc管理后台模版 | rainlevo</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?af94e3b5981427d708006e5dc693f5ff";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>










</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">rainlevo</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description">大漠游侠</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="https://github.com/raintao/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  
  <div class="algolia-popup popup search-popup">
    <div class="algolia-search">
      <div class="algolia-search-input-icon">
        <i class="fa fa-search"></i>
      </div>
      <div class="algolia-search-input" id="algolia-search-input"></div>
    </div>

    <div class="algolia-results">
      <div id="algolia-stats"></div>
      <div id="algolia-hits"></div>
      <div id="algolia-pagination" class="algolia-pagination"></div>
    </div>

    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
  </div>




    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/08/17/vue-npm-framework/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="rainlevo">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="https://avatars3.githubusercontent.com/u/20055312?v=3&u=9d73880d4f9830a5ecbb2fe4dae4b92e0801ac95&s=400">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="rainlevo">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">一个简单的脚手架drop-cli,vue的组件库模版，移动端架构和pc管理后台模版</h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-08-17T20:53:27+08:00">
                2018-08-17
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/脚手架/" itemprop="url" rel="index">
                    <span itemprop="name">脚手架</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/脚手架/框架/" itemprop="url" rel="index">
                    <span itemprop="name">框架</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/脚手架/框架/vue/" itemprop="url" rel="index">
                    <span itemprop="name">vue</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/脚手架/框架/vue/npm包/" itemprop="url" rel="index">
                    <span itemprop="name">npm包</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2018/08/17/vue-npm-framework/" class="leancloud_visitors" data-flag-title="一个简单的脚手架drop-cli,vue的组件库模版，移动端架构和pc管理后台模版">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数 </span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="drop-cli"><a href="#drop-cli" class="headerlink" title="drop-cli"></a>drop-cli</h1><blockquote>
<p>一个简单的脚手架,可添加不同的模版/框架</p>
<h4 id="1-安装并查看drop-cli的模版"><a href="#1-安装并查看drop-cli的模版" class="headerlink" title="1. 安装并查看drop-cli的模版"></a>1. 安装并查看<a href="https://github.com/raintao/drop-cli.git" target="_blank" rel="external">drop-cli</a>的模版</h4></blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">$ npm install drop-cli -g</div><div class="line">$ drop-cli list</div></pre></td></tr></table></figure>
<h4 id="2-选择模板并创建自己的项目"><a href="#2-选择模板并创建自己的项目" class="headerlink" title="2. 选择模板并创建自己的项目"></a>2. 选择模板并创建自己的项目</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">$ drop-cli init</div><div class="line">$ gulp-html-front // 输入一个模版</div><div class="line">$ gulp-html-test  // 输入自己的项目名称</div><div class="line">$ cd gulp-html-test</div><div class="line">$ npm install</div></pre></td></tr></table></figure>
<h4 id="3-模版链接"><a href="#3-模版链接" class="headerlink" title="3. 模版链接"></a>3. 模版链接</h4><h5 id="vue-pc-admin-front-基于vue全家桶的一个pc端后台管理系统"><a href="#vue-pc-admin-front-基于vue全家桶的一个pc端后台管理系统" class="headerlink" title="vue-pc-admin-front : 基于vue全家桶的一个pc端后台管理系统"></a><a href="https://github.com/raintao/vue-pc-admin-front" target="_blank" rel="external">vue-pc-admin-front</a> : 基于vue全家桶的一个pc端后台管理系统</h5><h5 id="vue-mobile-front-基于vue全家桶的一个移动端架构模版"><a href="#vue-mobile-front-基于vue全家桶的一个移动端架构模版" class="headerlink" title="vue-mobile-front : 基于vue全家桶的一个移动端架构模版"></a><a href="https://github.com/raintao/vue-mobile-front" target="_blank" rel="external">vue-mobile-front</a> : 基于vue全家桶的一个移动端架构模版</h5><h5 id="drop-element-制作vue组件库的npm模版"><a href="#drop-element-制作vue组件库的npm模版" class="headerlink" title="drop-element : 制作vue组件库的npm模版"></a><a href="https://github.com/raintao/drop-element" target="_blank" rel="external">drop-element</a> : 制作vue组件库的npm模版</h5><h5 id="gulp-html-front-基于gulp的多页应用模版，less-es6"><a href="#gulp-html-front-基于gulp的多页应用模版，less-es6" class="headerlink" title="gulp-html-front : 基于gulp的多页应用模版，less,es6"></a><a href="https://github.com/raintao/gulp-html-front" target="_blank" rel="external">gulp-html-front</a> : 基于gulp的多页应用模版，less,es6</h5><h1 id="vue-pc-admin-front"><a href="#vue-pc-admin-front" class="headerlink" title="vue-pc-admin-front"></a><a href="https://github.com/raintao/vue-pc-admin-front" target="_blank" rel="external">vue-pc-admin-front</a></h1><blockquote>
<p>PC后台管理Vue架构(vue+ vue-router + store+ axios + scss + svg + element-ui)</p>
</blockquote>
<h2 id="安装使用"><a href="#安装使用" class="headerlink" title="安装使用"></a>安装使用</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">$ git clone https://github.com/raintao/vue-pc-admin-front.git</div><div class="line">$ cd vue-pc-admin-front</div><div class="line">$ npm install</div><div class="line">$ npm start</div></pre></td></tr></table></figure>
<h2 id="也可利用drop-cli脚手架安装模版"><a href="#也可利用drop-cli脚手架安装模版" class="headerlink" title="也可利用drop-cli脚手架安装模版"></a>也可利用<a href="https://github.com/raintao/drop-cli.git" target="_blank" rel="external">drop-cli</a>脚手架安装模版</h2><h4 id="1、-安装drop-cli"><a href="#1、-安装drop-cli" class="headerlink" title="1、 安装drop-cli"></a>1、 安装drop-cli</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">$ npm install drop-cli -g</div><div class="line">$ drop-cli list</div></pre></td></tr></table></figure>
<h4 id="2、选择模板并创建自己的项目"><a href="#2、选择模板并创建自己的项目" class="headerlink" title="2、选择模板并创建自己的项目"></a>2、选择模板并创建自己的项目</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">$ drop-cli init</div><div class="line">$ gulp-html-front // 输入一个模版</div><div class="line">$ gulp-html-test  // 输入自己的项目名称</div><div class="line">$ cd gulp-html-test</div><div class="line">$ npm install</div></pre></td></tr></table></figure>
<blockquote>
<p>因为npm安装插件是从国外服务器下载，受网络影响大，可能出现异常,一般我们常用<a href="http://npm.taobao.org" target="_blank" rel="external">cnpm</a>来代替</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">npm install cnpm -g --registry=https://registry.npm.taobao.org</div></pre></td></tr></table></figure>
<blockquote>
<p>这里推荐使用<a href="https://yarn.bootcss.com/" target="_blank" rel="external">yarn</a>, yarn就是一个类似于npm的包管理工具，它是由facebook推出并开源。鉴于facebook在前端界的影响力，yarn一面世就很受瞩目，受到了前端界的广泛欢迎。与npm相比，yarn有着众多的优势，主要的优势在于：速度快，离线模式，版本控制。<a href="https://yarn.bootcss.com/" target="_blank" rel="external">详情点这里</a></p>
</blockquote>
<h1 id="vue-pc-admin-front模板简单介绍"><a href="#vue-pc-admin-front模板简单介绍" class="headerlink" title="vue-pc-admin-front模板简单介绍"></a><a href="https://github.com/raintao/vue-pc-admin-front" target="_blank" rel="external">vue-pc-admin-front</a>模板简单介绍</h1><h2 id="1-element-ui"><a href="#1-element-ui" class="headerlink" title="1.element-ui"></a>1.element-ui</h2><p>   由饿了么前端团队推出的 element-ui 是一个基于 Vue.js 的pc端组件库。已发布了 2.4.6 版本，支持了vue2。引入方式为:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">// ui框架  </div><div class="line">import Vue from &apos;vue&apos;;</div><div class="line">import ElementUI from &apos;element-ui&apos;;</div><div class="line">import &apos;element-ui/lib/theme-chalk/index.css&apos;;</div><div class="line">import App from &apos;./App.vue&apos;;</div><div class="line"></div><div class="line">Vue.use(ElementUI);</div><div class="line"></div><div class="line">new Vue(&#123;</div><div class="line">el: &apos;#app&apos;,</div><div class="line">render: h =&gt; h(App)</div><div class="line">&#125;);</div></pre></td></tr></table></figure></p>
<p>    当然也可按需引入，来减少项目的大小。具体怎么用请参考官网：<a href="http://element-cn.eleme.io/#/zh-CN/component/quickstart" target="_blank" rel="external">Element-ui官网手册</a></p>
<h2 id="2-字体图标用的是vue-svgicon"><a href="#2-字体图标用的是vue-svgicon" class="headerlink" title="2.字体图标用的是vue-svgicon ,"></a>2.字体图标用的是vue-svgicon ,</h2><p>  可以在<a href="http://www.iconfont.cn/" target="_blank" rel="external">阿里巴巴矢量图标库</a>上下载项目需要的svg图标。放在目录src/assets/svg下，然后yarn svg就可以生成对应的js文件<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">1、 在main.js中引用</div><div class="line">// in main.js first line 兼容ie</div><div class="line">import &apos;vue-svgicon/dist/polyfill&apos;</div><div class="line">// import all icons</div><div class="line">import * as svgicon from &apos;vue-svgicon&apos;</div><div class="line">import &apos;./views/icons&apos;</div><div class="line">Vue.use(svgicon, &#123;</div><div class="line">tagName: &apos;icon&apos;</div><div class="line">&#125;)</div><div class="line"></div><div class="line">2、 在html中的使用方法</div><div class="line"> &lt;icon name=&quot;right&quot; width=&quot;18&quot; height=&quot;16&quot; color=&quot;#D0D0D0&quot;&gt;&lt;/icon&gt;</div><div class="line"> &lt;icon icon=&quot;right&quot; width=&quot;18&quot; height=&quot;16&quot; color=&quot;#D0D0D0&quot;&gt;&lt;/icon&gt;</div></pre></td></tr></table></figure></p>
<p><a href="https://github.com/MMF-FE/vue-svgicon" target="_blank" rel="external">vue-svgicon</a>的命令配置使用方法请参照<a href="https://github.com/MMF-FE/vue-svgicon" target="_blank" rel="external">vue-svgicon的github地址</a></p>
<h2 id="3-页面title使用的是vue-meta"><a href="#3-页面title使用的是vue-meta" class="headerlink" title="3.页面title使用的是vue-meta"></a>3.页面title使用的是<a href="https://github.com/declandewet/vue-meta" target="_blank" rel="external">vue-meta</a></h2><p>1、在main.js引入<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">import Meta from &apos;vue-meta&apos;</div><div class="line"></div><div class="line">Vue.use(Meta, &#123;</div><div class="line">  keyName: &apos;metaInfo&apos;</div><div class="line">&#125;)</div></pre></td></tr></table></figure></p>
<p>2、 在js中使用 和data created methods并列<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">metaInfo: &#123;</div><div class="line">    title: &apos;实例使用meta&apos;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>3、 更多用法参考<a href="https://github.com/declandewet/vue-meta" target="_blank" rel="external">项目地址</a></p>
<h2 id="4-代码风格-vue-property-decorator"><a href="#4-代码风格-vue-property-decorator" class="headerlink" title="4. 代码风格 vue-property-decorator"></a>4. 代码风格 <a href="https://github.com/kaorun343/vue-property-decorator" target="_blank" rel="external">vue-property-decorator</a></h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">import &#123; Vue, Component, Prop &#125; from &apos;vue-property-decorator&apos;</div><div class="line"></div><div class="line">@Component</div><div class="line">export default class YourComponent extends Vue &#123;</div><div class="line">  @Prop(Number) propA!: number</div><div class="line">  @Prop(&#123; default: &apos;default value&apos; &#125;) propB!: string</div><div class="line">  @Prop([String, Boolean]) propC: string | boolean</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>is equivalent to<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">export default &#123;</div><div class="line">  props: &#123;</div><div class="line">    propA: &#123;</div><div class="line">      type: Number</div><div class="line">    &#125;,</div><div class="line">    propB: &#123;</div><div class="line">      default: &apos;default value&apos;</div><div class="line">    &#125;,</div><div class="line">    propC: &#123;</div><div class="line">      type: [String, Boolean]</div><div class="line">    &#125;,</div><div class="line">  &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>具体使用方法请参考<a href="https://github.com/kaorun343/vue-property-decorator" target="_blank" rel="external">github</a> 或者文件夹src/views/page下的demo页面</p>
<h2 id="5-vuex的分发封装vuex-class"><a href="#5-vuex的分发封装vuex-class" class="headerlink" title="5. vuex的分发封装vuex-class"></a>5. vuex的分发封装<a href="https://github.com/ktsn/vuex-class" target="_blank" rel="external">vuex-class</a></h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">import Vue from &apos;vue&apos;</div><div class="line">import Component from &apos;vue-class-component&apos;</div><div class="line">import &#123;</div><div class="line">  State,</div><div class="line">  Getter,</div><div class="line">  Action,</div><div class="line">  Mutation,</div><div class="line">  namespace</div><div class="line">&#125; from &apos;vuex-class&apos;</div><div class="line"></div><div class="line">const someModule = namespace(&apos;path/to/module&apos;)</div><div class="line"></div><div class="line">@Component</div><div class="line">export class MyComp extends Vue &#123;</div><div class="line">  @State(&apos;foo&apos;) stateFoo</div><div class="line">  @State(state =&gt; state.bar) stateBar</div><div class="line">  @Getter(&apos;foo&apos;) getterFoo</div><div class="line">  @Action(&apos;foo&apos;) actionFoo</div><div class="line">  @Mutation(&apos;foo&apos;) mutationFoo</div><div class="line">  @someModule.Getter(&apos;foo&apos;) moduleGetterFoo</div><div class="line"></div><div class="line">  // If the argument is omitted, use the property name</div><div class="line">  // for each state/getter/action/mutation type</div><div class="line">  @State foo</div><div class="line">  @Getter bar</div><div class="line">  @Action baz</div><div class="line">  @Mutation qux</div><div class="line"></div><div class="line">  created () &#123;</div><div class="line">    this.stateFoo // -&gt; store.state.foo</div><div class="line">    this.stateBar // -&gt; store.state.bar</div><div class="line">    this.getterFoo // -&gt; store.getters.foo</div><div class="line">    this.actionFoo(&#123; value: true &#125;) // -&gt; store.dispatch(&apos;foo&apos;, &#123; value: true &#125;)</div><div class="line">    this.mutationFoo(&#123; value: true &#125;) // -&gt; store.commit(&apos;foo&apos;, &#123; value: true &#125;)</div><div class="line">    this.moduleGetterFoo // -&gt; store.getters[&apos;path/to/module/foo&apos;]</div><div class="line">  &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>具体使用方法请参考<a href="https://github.com/ktsn/vuex-class" target="_blank" rel="external">github</a> 或者文件夹src/views/page下的demo页面</p>
<h1 id="drop-element"><a href="#drop-element" class="headerlink" title="drop-element"></a><a href="https://github.com/raintao/drop-element" target="_blank" rel="external">drop-element</a></h1><blockquote>
<p>vue组件库（可作为一个快速开发vue组件并发布到npm的模版)</p>
</blockquote>
<h2 id="完整引入drop-element"><a href="#完整引入drop-element" class="headerlink" title="完整引入drop-element"></a>完整引入drop-element</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">import Vue from &apos;vue&apos;;</div><div class="line">import DropElement from &apos;drop-element&apos;;</div><div class="line">import App from &apos;./App.vue&apos;;</div><div class="line"></div><div class="line">Vue.use(DropElement);</div><div class="line"></div><div class="line">new Vue(&#123;</div><div class="line">el: &apos;#app&apos;,</div><div class="line">render: h =&gt; h(App)</div><div class="line">&#125;);</div></pre></td></tr></table></figure>
<h2 id="通过js引入"><a href="#通过js引入" class="headerlink" title="通过js引入"></a>通过js引入</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">// 完整demo在lib/demo.html</div><div class="line">&lt;script src=&quot;./drop-element.js&quot;&gt;&lt;/script&gt;</div></pre></td></tr></table></figure>
<h2 id="做为vue组件模版"><a href="#做为vue组件模版" class="headerlink" title="做为vue组件模版"></a>做为vue组件模版</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">$ git clone https://github.com/raintao/drop-element.git</div><div class="line">$ cd drop-element</div><div class="line">$ npm install</div><div class="line">$ npm start</div></pre></td></tr></table></figure>
<h2 id="也可利用drop-cli脚手架安装模版-1"><a href="#也可利用drop-cli脚手架安装模版-1" class="headerlink" title="也可利用drop-cli脚手架安装模版"></a>也可利用<a href="https://github.com/raintao/drop-cli.git" target="_blank" rel="external">drop-cli</a>脚手架安装模版</h2><h4 id="1-安装drop-cli"><a href="#1-安装drop-cli" class="headerlink" title="1. 安装drop-cli"></a>1. 安装drop-cli</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">$ npm install drop-cli -g</div><div class="line">$ drop-cli list</div></pre></td></tr></table></figure>
<h4 id="2-选择模板并创建自己的项目-1"><a href="#2-选择模板并创建自己的项目-1" class="headerlink" title="2.选择模板并创建自己的项目"></a>2.选择模板并创建自己的项目</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">$ drop-cli init</div><div class="line">$ gulp-html-front // 输入一个模版</div><div class="line">$ gulp-html-test  // 输入自己的项目名称</div><div class="line">$ cd gulp-html-test</div><div class="line">$ npm install</div></pre></td></tr></table></figure>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>坚持原创技术分享,您的支持将鼓励我继续创作！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="/images/wechat.png" alt="rainlevo WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="/images/zhifubao.png" alt="rainlevo Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/vue/" rel="tag"># vue</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/02/22/canvas/" rel="next" title="超多经典 canvas 实例">
                <i class="fa fa-chevron-left"></i> 超多经典 canvas 实例
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="uyan_frame"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="https://avatars3.githubusercontent.com/u/20055312?v=3&u=9d73880d4f9830a5ecbb2fe4dae4b92e0801ac95&s=400"
               alt="rainlevo" />
          <p class="site-author-name" itemprop="name">rainlevo</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
           
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives/">
                <span class="site-state-item-count">12</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">14</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">16</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/rss2.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/raintao" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.jianshu.com/u/3561d2120d63" target="_blank" title="简书">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  简书
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              友情链接
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="https://juejin.im/timeline" title="掘金" target="_blank">掘金</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://github.com/" title="github" target="_blank">github</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://music.163.com/#/playlist?id=30592034" title="网易云音乐" target="_blank">网易云音乐</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://theme-next.iissnan.com/" title="next" target="_blank">next</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#drop-cli"><span class="nav-number">1.</span> <span class="nav-text">drop-cli</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-安装并查看drop-cli的模版"><span class="nav-number">1.0.0.1.</span> <span class="nav-text">1. 安装并查看drop-cli的模版</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-选择模板并创建自己的项目"><span class="nav-number">1.0.0.2.</span> <span class="nav-text">2. 选择模板并创建自己的项目</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-模版链接"><span class="nav-number">1.0.0.3.</span> <span class="nav-text">3. 模版链接</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#vue-pc-admin-front-基于vue全家桶的一个pc端后台管理系统"><span class="nav-number">1.0.0.3.1.</span> <span class="nav-text">vue-pc-admin-front : 基于vue全家桶的一个pc端后台管理系统</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#vue-mobile-front-基于vue全家桶的一个移动端架构模版"><span class="nav-number">1.0.0.3.2.</span> <span class="nav-text">vue-mobile-front : 基于vue全家桶的一个移动端架构模版</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#drop-element-制作vue组件库的npm模版"><span class="nav-number">1.0.0.3.3.</span> <span class="nav-text">drop-element : 制作vue组件库的npm模版</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#gulp-html-front-基于gulp的多页应用模版，less-es6"><span class="nav-number">1.0.0.3.4.</span> <span class="nav-text">gulp-html-front : 基于gulp的多页应用模版，less,es6</span></a></li></ol></li></ol></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#vue-pc-admin-front"><span class="nav-number">2.</span> <span class="nav-text">vue-pc-admin-front</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#安装使用"><span class="nav-number">2.1.</span> <span class="nav-text">安装使用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#也可利用drop-cli脚手架安装模版"><span class="nav-number">2.2.</span> <span class="nav-text">也可利用drop-cli脚手架安装模版</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1、-安装drop-cli"><span class="nav-number">2.2.0.1.</span> <span class="nav-text">1、 安装drop-cli</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2、选择模板并创建自己的项目"><span class="nav-number">2.2.0.2.</span> <span class="nav-text">2、选择模板并创建自己的项目</span></a></li></ol></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#vue-pc-admin-front模板简单介绍"><span class="nav-number">3.</span> <span class="nav-text">vue-pc-admin-front模板简单介绍</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-element-ui"><span class="nav-number">3.1.</span> <span class="nav-text">1.element-ui</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-字体图标用的是vue-svgicon"><span class="nav-number">3.2.</span> <span class="nav-text">2.字体图标用的是vue-svgicon ,</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-页面title使用的是vue-meta"><span class="nav-number">3.3.</span> <span class="nav-text">3.页面title使用的是vue-meta</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-代码风格-vue-property-decorator"><span class="nav-number">3.4.</span> <span class="nav-text">4. 代码风格 vue-property-decorator</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-vuex的分发封装vuex-class"><span class="nav-number">3.5.</span> <span class="nav-text">5. vuex的分发封装vuex-class</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#drop-element"><span class="nav-number">4.</span> <span class="nav-text">drop-element</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#完整引入drop-element"><span class="nav-number">4.1.</span> <span class="nav-text">完整引入drop-element</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#通过js引入"><span class="nav-number">4.2.</span> <span class="nav-text">通过js引入</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#做为vue组件模版"><span class="nav-number">4.3.</span> <span class="nav-text">做为vue组件模版</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#也可利用drop-cli脚手架安装模版-1"><span class="nav-number">4.4.</span> <span class="nav-text">也可利用drop-cli脚手架安装模版</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-安装drop-cli"><span class="nav-number">4.4.0.1.</span> <span class="nav-text">1. 安装drop-cli</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-选择模板并创建自己的项目-1"><span class="nav-number">4.4.0.2.</span> <span class="nav-text">2.选择模板并创建自己的项目</span></a></li></ol></li></ol></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2016 - 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">rainlevo</span>
</div>


<div class="powered-by">
  由raintao <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  
    

    
      <!-- UY BEGIN -->
      <script type="text/javascript" src="http://v2.uyan.cc/code/uyan.js?uid=2136697"></script>
      <!-- UY END -->
    
  





  






  




  
  
  
  <link rel="stylesheet" href="/lib/algolia-instant-search/instantsearch.min.css">

  
  
  <script src="/lib/algolia-instant-search/instantsearch.min.js"></script>
  

  <script src="/js/src/algolia-search.js?v=5.1.1"></script>



  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("kwayXY98SJfg9qtSMXVVlm3J-gzGzoHsz", "OQwFnQ1HSCcpThOVrwj5bzRL");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  

  

  

</body>
</html>
